﻿<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection" />
    <title>移动数据查询（公司）</title>
    <!--使用phonegap框架时引入脚本一定要放在最上面----->
    <script type="text/javascript" charset="utf-8" src="js/phonegap-1.4.1.js"></script>
    <script src="js/jquery/jquery-1.8.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/config.js" type="text/javascript" charset="utf-8"></script>
    <link href="css/style.css" rel="stylesheet" type="text/css"  charset="utf-8"/>
    <link href="css/btnsty.css" rel="stylesheet" type="text/css" charset="utf-8"/>
    <link href="css/editform.css" rel="stylesheet" type="text/css" charset="utf-8"/>
    <link href="css/global.css" rel="stylesheet" type="text/css" charset="utf-8"/>
    <script src="js/Toast.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" charset="utf-8" src="js/barcodescanner.js"></script>
    <script type="text/javascript" charset="utf-8">
        $(function () {
            $("#btnbarcode").click(function () {
                window.plugins.barcodeScanner.scan(
	                    BarcodeScanner.Type.ALL_CODE_TYPES,
	                    function (result) {
	                        if ($.trim(result) == "") {
	                            alert("无效的条码！");
	                        } else {
	                            $("#txtbarcode").val(result);
	                            GetData($("#txtbarcode").val());
	                        }
	                    },
	                    function (error) {
	                        alert("扫描失败：" + result);
	                    },
	            		{
	            		    installTitle: "安装提示",
	            		    installMessage: "是否安装开源免费的ZXing二维码扫描器",
	            		    yesString: "确定",
	            		    noString: "取消"
	            		}
	        );

            });

            ClearData();
            //这个是在页面回车时候会触发该方法
            $("#txtbarcode").keydown(function (event) {
                if (event.which == 13) {
                    GetData($("#txtbarcode").val());
                }
            });
            $("#btnfind").click(function () {
                GetData($("#txtbarcode").val());
            });
            //            $("#btnbarcode").live("click", function () {
            //                js2java();
            //            });
        });
        function js2java() {
            alert("barcode");
            window.plugins.barcodeScanner.scan(
	        BarcodeScanner.Type.QR_CODE,
	        function (result) {
	            $("#txtbarcode").val("" + result);
	        },
	        function (error) {
	            showtoast("扫描失败：" + result);
	        },
	        {
	            installTitle: "安装提示",
	            installMessage: "是否安装开源免费的ZXing二维码扫描器",
	            yesString: "确定",
	            noString: "取消"
	        }
            );
        }
        function ClearData() {
            $("#txtcode").text("");
            $("#txtname").text("");
            $("#txtsaldate").text("");
            $("#txtpurqty").text("");
            $("#txtsalqty").text("");
            $("#txtinvqty").text("");
            $("#txtdcount").text("");
            $("#txtscount").text("");
            $("#txtzk").text("");
            $("#txtxxl").text("");
        }
        function GetData(code) {
            showtoast("数据加载中...", null, null, null);
            $.ajax({
                url: url_path + "/ajaxdata/Default.aspx",
                type: "POST",
                data: { aciton: 'GetSaleByCompRpt', barcode: code },
                timeout: 30000,
                dataType: "text",
                success: function (data) {
                    var msg = $.trim(data);
                    if (msg == "NO_DATA") {
                        ClearData();
                        showtoast("没有数据可显示！", null, null, null);
                    } else {
                        var orderObj = JSON.parse(msg);
                        for (var i = 0; i < orderObj.length; i++) {
                            $("#txtcode").text(orderObj[i].materialcode);
                            $("#txtname").text(orderObj[i].materialname);
                            $("#txtsaldate").text(orderObj[i].saldate);
                            $("#txtpurqty").text(orderObj[i].purqty);
                            $("#txtsalqty").text(orderObj[i].salqty);
                            $("#txtinvqty").text(orderObj[i].actualqty);
                            $("#txtdcount").text(orderObj[i].dcount);
                            $("#txtscount").text(orderObj[i].scount);
                            $("#txtzk").text(orderObj[i].zkl);
                            $("#txtxxl").text(orderObj[i].xxl);
                        }
                    }
                },
                error: function () {
                    showtoast("通讯超时,请检查网络.", null, 100, 100);
                }
            });
        }
    </script>
</head>
<body>
    <div id="header" class="head">
        <div class="wrap">
            <i class=" menu_back2"><a href="index.html"></a></i>
            <div class="title">
                <span class="title_d">
                    <p>
                        移动数据查询（公司）</p>
                </span>
                <div class="clear">
                </div>
            </div>
        </div>
        <div class="logo_msk">
        </div>
    </div>
    <div id="container">
        <div id="content" style="background: #fff; margin: 8px;">
            <table class="edit_table">
                <tbody>
                    <tr>
                        <td class="tdl">
                            商品条码：
                        </td>
                        <td>
                            <input id="txtbarcode" class="ipt ipt-sku" type="text" placeholder="输入货品条码" />
                            <a id="btnfind" href="#" class="button small medium-blue">GO</a>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdl">
                            货号：
                        </td>
                        <td>
                            <label id="txtcode">
                                1213213232132</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdl">
                            货品名称：
                        </td>
                        <td>
                            <label id="txtname">
                                休闲裤</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdl">
                            首销日期：
                        </td>
                        <td>
                            <label id="txtsaldate">
                                2015-6-6</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdl">
                            累计到货数量：
                        </td>
                        <td>
                            <label id="txtpurqty">
                                12</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdl">
                            累计销售数量：
                        </td>
                        <td>
                            <label id="txtsalqty">
                                20</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdl">
                            库存数量：
                        </td>
                        <td>
                            <label id="txtinvqty">
                                12</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdl">
                            库存店数：
                        </td>
                        <td>
                            <label id="txtdcount">
                                30</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdl">
                            店均销售：
                        </td>
                        <td>
                            <label id="txtscount">
                                12</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdl">
                            销售折扣：
                        </td>
                        <td>
                            <label id="txtzk">
                                100</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdl">
                            销馨率：
                        </td>
                        <td>
                            <label id="txtxxl">
                                12</label>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</body>
</html>
